package com.kuun.mysql.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.kuun.domain.Customer;

public interface CustomerRepository extends JpaRepository<Customer, Integer> {

	public Customer findByCustomerId(Integer customerId) ;

	@Query("select o from Customer o where o.customerName=?1")
	public Customer findCustomerInfoByCustomerName(String customerName);
	
	@Query("select password from Customer where customerName= ?1")
	public String findPasswordInfoByCustomerName(String customerName);
	
	@Query("select o from Customer o where o.phone= :phone")
	public Customer findCustomerInfoByPhone(@Param("phone")String phone);
	
//	@Modifying
//	@Query("update Customer o set o.customerName= :customerName where o.customerId= :customerId")
//	public void updateCustomerNameByCustomerId(@Param("customerId")Integer customerId,@Param("customerName")String customerName);
	
	@Modifying
	@Query("update Customer o set o.password= :password where o.customerName= :customerName")
	public void updatePasswByCustomerName(@Param("customerName")String customerName,@Param("password")String password);
	
	@Modifying
	@Query("delete from Customer o where o.customerName =?1")
	public void deleteCustomerInfoByCustomerName(String customerName) ;
	
}
